package 剑指专题.链表;


/*
 * Author：江松
 * Date：2023/3/26 10:26
 *
 反转链表:
 1,哈希表，数组存储
 2，直接用临时变量
 */

public class Main2 {
    public class ListNode {
        int val;
        ListNode next = null;

        ListNode(int val) {
            this.val = val;
        }
    }
    public ListNode ReverseList(ListNode head) {
        ListNode pre=null,now=head;
        while (now!=null){
            ListNode t=now;
            now=now.next;
            t.next=pre;
            pre =t;
        }
        return pre;
    }
}
